import 'dart:convert' show json;
import 'user.dart';

class Comment {
  String cmt_type;
  String content;
  String ctime;
  String data_id;
  String id;
  String like_count;
  String precid;
  String preuid;
  String status;
  String voicetime;
  String voiceuri;
  List<dynamic> precmt;
  User user;

  Comment.fromParams(
      {this.cmt_type,
      this.content,
      this.ctime,
      this.data_id,
      this.id,
      this.like_count,
      this.precid,
      this.preuid,
      this.status,
      this.voicetime,
      this.voiceuri,
      this.precmt,
      this.user});

  Comment.fromJson(jsonRes) {
    if (jsonRes.toString() == "[]" || jsonRes.toString() == null) {
      return;
    }
    cmt_type = jsonRes['cmt_type'];
    content = jsonRes['content'];
    ctime = jsonRes['ctime'];
    data_id = jsonRes['data_id'];
    id = jsonRes['id'];
    like_count = jsonRes['like_count'];
    precid = jsonRes['precid'];
    preuid = jsonRes['preuid'];
    status = jsonRes['status'];
    voicetime = jsonRes['voicetime'];
    voiceuri = jsonRes['voiceuri'];
    precmt = jsonRes['precmt'] == null ? null : [];

    for (var precmtItem in precmt == null ? [] : jsonRes['precmt']) {
      precmt.add(precmtItem);
    }

    user = jsonRes['user'] == null ? null : new User.fromJson(jsonRes['user']);
  }

  @override
  String toString() {
    return '{"cmt_type": ${cmt_type != null ? '${json.encode(cmt_type)}' : 'null'},"content": ${content != null ? '${json.encode(content)}' : 'null'},"ctime": ${ctime != null ? '${json.encode(ctime)}' : 'null'},"data_id": ${data_id != null ? '${json.encode(data_id)}' : 'null'},"id": ${id != null ? '${json.encode(id)}' : 'null'},"like_count": ${like_count != null ? '${json.encode(like_count)}' : 'null'},"precid": ${precid != null ? '${json.encode(precid)}' : 'null'},"preuid": ${preuid != null ? '${json.encode(preuid)}' : 'null'},"status": ${status != null ? '${json.encode(status)}' : 'null'},"voicetime": ${voicetime != null ? '${json.encode(voicetime)}' : 'null'},"voiceuri": ${voiceuri != null ? '${json.encode(voiceuri)}' : 'null'},"precmt": $precmt,"user": $user}';
  }
}
